const app = getApp()
const $api = require('../../../utils/api.js').API;
Page({
    data: {
        list:{},
    },
    onLoad: function(e){
        wx.showLoading()
        this.getList();
        this.setData({
            role:wx.getStorageSync('role')
        })
    },
    getList:function(){
        var that = this
        var data = {'uid':wx.getStorageSync('uid')}
        $api.get('phoneSee/list',data).then(res =>{
            //请求成功
            if(res.data.code == 1){
                wx.hideLoading()
                that.setData({
                    list:res.data.data
                })
            }
        }).catch(err => {
            //请求失败
            //console.log('error',err);
        })
    },
    userSee(e){
        var uid = e.target.dataset.uid
        wx.navigateTo({
            url: '/pages/job/info?uid='+uid
        })
    },
    edit:function(e){
        var id = e.target.dataset.id
        var type = e.target.dataset.type
        var that = this
        var data ={'id':id,'type':type}
        $api.put('phoneSee/edit',data).then(res => {
            //请求成功
            if(res.data.code == 1){
                wx.showLoading()
                that.getList();
                wx.showToast({
                    title:'成功',
                    duration:3000,//显示时长
                    mask:true,//是否显示透明蒙层，防止触摸穿透，默认：false  
                    icon:'none', //图标，支持"success"、"loading" 
                })
            }
        }).catch(err => {
            //请求失败
            //console.log('error',err);
        })
    },
    // del:function(e){
    //     var id = e.target.dataset.id
    //     var that = this
    //     var data ={'id':id}
    //     $api.delete('phoneSee/delete',data).then(res => {
    //         //请求成功
    //         if(res.data.code == 1){
    //             wx.showLoading()
    //             that.getList();
    //             wx.showToast({
    //                 title:'删除成功',
    //                 duration:3000,//显示时长
    //                 mask:true,//是否显示透明蒙层，防止触摸穿透，默认：false  
    //                 icon:'none', //图标，支持"success"、"loading" 
    //             })
    //         }
    //     }).catch(err => {
    //         //请求失败
    //         //console.log('error',err);
    //     })
    // },
    onShareAppMessage: function() {
        return {
            title: "天意美业直通车",
            path: "/pages/index/index?puid="+wx.getStorageSync('uid')
        };
      }
});